
package org.example.infrastructure.repository.orm.database.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.github.pagehelper.PageInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * 数据库持久层配置类
 *
 */
@Configuration
public class MybatisPlusConfig {

    /**
     * 分页插件
     */
//    @Bean
//    @ConditionalOnMissingBean
//    public MybatisPlusInterceptor mybatisPlusInterceptor() {
//        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
//        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
//        return interceptor;
//    }

    @Bean
    public PageInterceptor pageInterceptor() {
        PageInterceptor pageInterceptor = new PageInterceptor();
        Properties properties = new Properties();
        properties.setProperty("helperDialect", DbType.MYSQL.getDb()); // 根据你的数据库方言调整
        properties.setProperty("reasonable", "true");
        pageInterceptor.setProperties(properties);
        return pageInterceptor;
    }
}
